Managing Tags

Application needs to get the Tags information which is reported by Reader. Tags can be reported as part of an Inventory operation (reader.Actions.Inventory.perform) or a Read Access operation (reader.Actions.TagAccess.readEvent or reader.Actions.TagAccess.readWait).

Applications can also configure to receive Tag reports that indicate the results of access operations as shown beneath.

TagStorageSettings tagStorageSettings = reader.Config.getTagStorageSettings();

tagStorageSettings.enableAccessReports ( true);

reader.Config.setTagStorageSettings(tagStorageSettings);

Each Tag has a set of associated information along with it. During Inventory operation the Reader reports the EPC-ID of the Tag where as during Read-Access operation the requested Memory Bank Data is also reported apart from EPC-ID. In either case, there is additional information like PC-bits, RSSI, last time seen, tag seen count, etc that will be available for each Tag. This information is reported to the Application as TagData for each Tag reported by the Reader.

The Application can specify its customized memory bank data size using the function reader.Config.setTagStorageSettings. The Application shall initialize the tag storage settings for TagData so that all Tag allocations reflect the applications customized memory requirement.

TagStorageSettings tagStorageSettings = new TagStorageSettings(100, 512, 512);

reader.Config.setTagStorageSettings(tagStorageSettings);

Applications can also choose to enable/disable reporting of certain fields in TAG_DATA. Disabling certain fields can sometimes improve the performance as the Reader shall not be processing that information. It can also result in specific behavior. For e.g. disabling reporting of Antenna Id can result in application receiving as single unique tag even though they were multiple entries of the same tag reported from different Antennas. The following snippet shows enabling the reporting of PeakRSSI, Tag Seen count, PC and CRC only and disabling other fields like Antenna ID, time stamps and XPC.

TagStorageSettings tagStorageSettings = reader.Config.getTagStorageSettings();

TAG_FIELD[] tagField = new TAG_FIELD[4];

tagField[0] = TAG_FIELD.PC;

tagField[1] = TAG_FIELD.PEAK_RSSI;

tagField[2] = TAG_FIELD.TAG_SEEN_COUNT;

tagField[3] = TAG_FIELD.CRC;

tagStorageSettings.setTagFields(tagField);

reader.Config.setTagStorageSettings(tagStorageSettings);

Following are few use-cases that get Tags from the Reader:

Inventory operation: When RFID reader.Actions.Inventory.perform is invoked, the application will get notified of eventReadNotify if tags are reported back from the Reader if registered for read notification. When notified of the same, the event argument contains the tag data.

TagData.OpCode for inventory operation will be ACCESS_OPERATION_NONE, and TagData.OpStatus to be ignored.

// Simple Inventory with tag events

reader.Events.addEventsListener(new EventHandler());

TagData reportedTag = new TagData();

reader.Actions.Inventory.perform();

Thread.Sleep(1000);

reader.Actions.Inventory.stop();

// Read Notify Event handler

class EventHandler implements RfidEventsListener {

    // Read Event Notification

    public void eventReadNotify(RfidReadEvents e){

        TagData tag = e.getReadEventData().tagData;

        System.out.println("Tag ID " + tag.getTagID());

       

        if (tag.getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&

                tag.getOpStatus() == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS)

        {

            if (tag.getMemoryBankData().length() > 0) {

                System.out.println(" Mem Bank Data " + tag.getMemoryBankData());

            }

        }

 

    }

    // Status Event Notification

    public void eventStatusNotify(RfidStatusEvents e) {

        System.out.println("Status Notification " + e.StatusEventData.getStatusEventType());

    }

}

Application can call GetReadTags method to fetch tags by specifying the number of expected tags.

// Simple Inventory operation for 1 seconds and get the tags

// with GetReadTags method

reader.Actions.Inventory.perform();

Thread.sleep(1000);

reader.Actions.Inventory.stop();

TagData[] remainingTags = reader.Actions.getReadTags(100);

for(int nIndex = 0; nIndex < remainingTags.Length; nIndex++)

{

System.out.println(remainingTags[nIndex].TagID);

}

Single Tag – Read Access: When the application calls the method reader.Actions.TagAccess.readWait to read data from a specific memory bank of a particular tag, the method returns the TagData for which TagData.getOpCode will be ACCESS_OPERATION_READ, and TagData.getOpStatus indicating the result of the operation; if TagData.getOpStatus is ACCESS_SUCCESS, the requested memory bank data can be found in TagData.getMemoryBankData.

/*Simple Read Access Operation on Specific Tag*/

String tagId = "1234ABCD00000000000025B1";

TagAccess tagAccess = new TagAccess();

TagAccess.ReadAccessParams readParams = tagAccess.new ReadAccessParams();

TagData readAccessTag;

readParams.setAccessPassword(0);

readParams.setByteCount(8);

readParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);

readParams.setByteOffset(0);

readAccessTag = reader.Actions.TagAccess.readWait(tagId, readParams, null);

System.out.println(readAccessTag.getMemoryBank().toString() + " : " + readAccessTag.getMemoryBankData());

Multiple Tags – Read Access: When the application calls the method reader.Actions.TagAccess.readEvent to read data from a specific memory bank of multiple tags, the method returns immediately, and reports the Tags asynchronously as done in Inventory operation. Tags reported as part of read access operation will have TagData.getOpCode as ACCESS_OPERATION_READ, and TagData.getOpStatus indicating the result of the operation; if TagData.getOpStatus is ACCESS_SUCCESS, the requested memory bank data can be found in TagData.getMemoryBankData.

/*Simple Access Operation on Multiple Tags*/

reader.Events.setInventoryStartEvent(true);

reader.Events.setInventoryStopEvent(true);

reader.Events.setAccessStartEvent(true);

reader.Events.setAccessStopEvent(true);

TagAccess tagAccess = new TagAccess();

TagAccess.ReadAccessParams readParams = tagAccess.new ReadAccessParams();

readParams.setAccessPassword(0);

readParams.setByteCount(0);

readParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);

readParams.setByteOffset(0);

reader.Actions.TagAccess.readEvent(readParams, null, null);

Access Operation Sequence – Read Access: When the application calls the method reader.Actions.TagAccess.OperationSequence.performSequence further to adding operations for Read (using reader.Actions.TagAccess.OperationSequence.Add of ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ), the method reader.Actions.TagAccess.OperationSequence.performSequence returns immediately, and reports tags asynchronously.

/*Access Sequence Operation – reads all memory banks */

TagAccess tagAccess = new TagAccess();

TagAccess.Sequence opSequence = tagAccess.new Sequence(tagAccess);

TagAccess.Sequence.Operation op1 = opSequence.new Operation();

op1.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ);

op1.ReadAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_RESERVED);

op1.ReadAccessParams.setByteCount(0);

op1.ReadAccessParams.setByteOffset(0);

op1.ReadAccessParams.setAccessPassword(0);

reader.Actions.TagAccess.OperationSequence.Add(op1);

TagAccess.Sequence.Operation op2 = opSequence.new Operation();

op2.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ);

op2.ReadAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_EPC);

op2.ReadAccessParams.setByteCount(0);

op2.ReadAccessParams.setByteOffset(0);

op2.ReadAccessParams.setAccessPassword(0);

rfid3.Actions.TagAccess.OperationSequence.Add(op2);

TagAccess.Sequence.Operation op3 = opSequence.new Operation();

op3.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ);

op3.ReadAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_TID);

op3.ReadAccessParams.setByteCount(0);

op3.ReadAccessParams.setByteOffset(0);

op3.ReadAccessParams.setAccessPassword(0);

rfid3.Actions.TagAccess.OperationSequence.Add(op3);

TagAccess.Sequence.Operation op4 = opSequence.new Operation();

op4.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ);

op4.ReadAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);

op4.ReadAccessParams.setByteCount(0);

op4.ReadAccessParams.setByteOffset(0);

op4.ReadAccessParams.setAccessPassword(0);

reader.Actions.TagAccess.OperationSequence.Add(op4);

reader.Actions.TagAccess.OperationSequence.performSequence();

/* performs only for 2000 seconds.. */

Thread.sleep(2000);

reader.Actions.TagAccess.OperationSequence.stopSequence();